package ar.edu.uba.fi.jmit.aspecter;

import java.util.HashMap;
import java.util.Map;

import ar.edu.uba.fi.jmit.aspecter.core.WeavingInstrumentorFactory;
import ar.edu.uba.fi.jmit.aspecter.core.exception.AspecterException;
import ar.edu.uba.fi.jmit.aspecter.testUtils.WeavingInstrumentorPluginTestImpl;

public class PluginWeavingInstrumentorTestCase extends AspecterTestCase {

	public void test1() {
		Map<String, String> configuration = new HashMap<String, String>();
		try {
			WeavingInstrumentorPluginTestImpl weavingInstrumentor = 
				(WeavingInstrumentorPluginTestImpl) WeavingInstrumentorFactory.getInstance().
				getPluginInstrumentor("aName", "ar.edu.uba.fi.jmit.aspecter.testUtils.WeavingInstrumentorPluginTestImpl", configuration, "NORMAL");
			assertEquals("NORMAL", weavingInstrumentor.getPriority());
			assertEquals(configuration, weavingInstrumentor.getProperties());
		} catch (AspecterException e) {
			fail(e);
		}
	}
	
	public void testWrongClass() {
		Map<String, String> configuration = new HashMap<String, String>();
		try {
			WeavingInstrumentorFactory.getInstance().
				getPluginInstrumentor("aName", "ar.edu.uba.fi.jmit.aspecter.testUtils.WeavingInstrumentorPluginTestImplWrongSpelled", configuration, "NORMAL");
			fail("Exception should be thrown");
		} catch (AspecterException e) {
			//expected
		}
	}
	
	public void testNoEmptyConstructor() {
		Map<String, String> configuration = new HashMap<String, String>();
		try {
			WeavingInstrumentorFactory.getInstance().
				getPluginInstrumentor("aName", "ar.edu.uba.fi.jmit.aspecter.testUtils.WeavingInstrumentorPluginTestImpl2", configuration, "NORMAL");
			fail("Exception should be thrown");
		} catch (AspecterException e) {
			//expected
		}
	}
	
	public void testPrivateConstructor() {
		Map<String, String> configuration = new HashMap<String, String>();
		try {
			WeavingInstrumentorFactory.getInstance().
				getPluginInstrumentor("aName", "ar.edu.uba.fi.jmit.aspecter.testUtils.WeavingInstrumentorPluginTestImpl3", configuration, "NORMAL");
			fail("Exception should be thrown");
		} catch (AspecterException e) {
			//expected
		}
	}
}
